namespace NC.Infrastructure.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ChangeModel : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.TargetPersons", "Target_Id", "dbo.Targets");
            DropForeignKey("dbo.TargetPersons", "Id", "dbo.People");
            DropIndex("dbo.TargetPersons", new[] { "Id" });
            DropIndex("dbo.TargetPersons", new[] { "Target_Id" });
            DropPrimaryKey("dbo.TargetPersons");
            AddColumn("dbo.ApiRecords", "CreatedAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.People", "CreatedAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.TargetPersons", "TargetId", c => c.Int(nullable: false));
            AddColumn("dbo.TargetPersons", "PersonId", c => c.Int(nullable: false));
            AddColumn("dbo.TargetPersons", "CreatedAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.ContentExtendParams", "CreatedAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.UrlLists", "CreatedAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.Applies", "CreatedAt", c => c.DateTime(nullable: false));
            AlterColumn("dbo.TargetPersons", "Id", c => c.Int(nullable: false, identity: true));
            AddPrimaryKey("dbo.TargetPersons", "Id");
            DropColumn("dbo.ApiRecords", "CreateAt");
            DropColumn("dbo.People", "CreateAt");
            DropColumn("dbo.TargetPersons", "CreateAt");
            DropColumn("dbo.TargetPersons", "Target_Id");
            DropColumn("dbo.Applies", "CreateAt");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Applies", "CreateAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.TargetPersons", "Target_Id", c => c.Int());
            AddColumn("dbo.TargetPersons", "CreateAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.People", "CreateAt", c => c.DateTime(nullable: false));
            AddColumn("dbo.ApiRecords", "CreateAt", c => c.DateTime(nullable: false));
            DropPrimaryKey("dbo.TargetPersons");
            AlterColumn("dbo.TargetPersons", "Id", c => c.Int(nullable: false));
            DropColumn("dbo.Applies", "CreatedAt");
            DropColumn("dbo.UrlLists", "CreatedAt");
            DropColumn("dbo.ContentExtendParams", "CreatedAt");
            DropColumn("dbo.TargetPersons", "CreatedAt");
            DropColumn("dbo.TargetPersons", "PersonId");
            DropColumn("dbo.TargetPersons", "TargetId");
            DropColumn("dbo.People", "CreatedAt");
            DropColumn("dbo.ApiRecords", "CreatedAt");
            AddPrimaryKey("dbo.TargetPersons", "Id");
            CreateIndex("dbo.TargetPersons", "Target_Id");
            CreateIndex("dbo.TargetPersons", "Id");
            AddForeignKey("dbo.TargetPersons", "Id", "dbo.People", "Id");
            AddForeignKey("dbo.TargetPersons", "Target_Id", "dbo.Targets", "Id");
        }
    }
}
